/* -----------------------------------------------------------
 * Author: Maria Powell
 * Testing Function: fullDeckCount()
 * Function Description: This function counts the deck of a given
 * 			player and a given card. It adds up the count of that 
 * 			card (of deck, discard pile, and hand) and returns it.
 * What to test: Test will ensure that given card is properly 
 * 	 			 counted for a given player.
 * How to test: This will be tested by manually setting the gameState
 * 				and then call the function to check if the proper
 *  			integer (card count) is returned. 
 -----------------------------------------------------------*/

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

//Set NOISY test to 0 to remove printfs from output console
#define NOISY_TEST 1

int main()
{
	//Initialization
	int i = 0;
	int returnEstate = 0;
	int returnSmithy = 0;
	int returnZero = 0;
	int numPlayer = 2;
	int numDeckSmithyCards = 1;
	int numHandSmithyCards = 2;
	int numDiscardSmithyCards = 3;
	int numDeckEstateCards = 1;
	int numHandEstateCards = 2;
	int numDiscardEstateCards = 3;
	int ShouldBeEstateNumber = 6;
	int ShouldBeSmithyNumber = 6;
	int ShouldBeZero = 0;
	int firstPlayer = 0;
	int secondPlayer = 1;	
	int length_1 = numDeckEstateCards + numDeckSmithyCards;
	int length_2 = numHandEstateCards + numHandSmithyCards;
	int length_3 = numDiscardEstateCards + numDiscardSmithyCards;
	struct gameState G;
	
	printf("TESTING  fullDeckCount()\n");
	#if (NOISY_TEST == 1)
		printf("Setting gameState Values:\n");
		printf("Number of Players: 2\n");
		printf("Estate Cards In Full Deck - Player 1: 6\n");
		printf("Smithy Cards In Full Deck - Player 1: 6\n");
		printf("Player 2 has no cards set\n");
	#endif


	//clear gameState 
	memset(&G, 23, sizeof(struct gameState)); 
	
	G.numPlayers = numPlayer; 					//setting player number

	//DECK Setting
	G.deckCount[firstPlayer] = 2;
	G.deckCount[secondPlayer] = 0;
	for(i = 0; i <  numDeckEstateCards; i++)    //set Estate card number
	{
		G.deck[firstPlayer][i] = estate;
	}
	for(i = numDeckEstateCards; i < length_1; i ++)  	//set Smithy card number 
	{
		G.deck[firstPlayer][i] = smithy;
	}
	
	//HAND Setting
	G.handCount[firstPlayer] = 4;
	G.handCount[secondPlayer] = 0;
   	for(i = 0; i <  numHandEstateCards; i++)    //set Estate card number
	{
		G.hand[firstPlayer][i] = estate;
	}
	for(i = numHandEstateCards; i < length_2; i ++)  	//set Smithy card number
	{
		G.hand[firstPlayer][i] = smithy;
	}

	//DISCARD Setting
	G.discardCount[firstPlayer] = 6;
	G.discardCount[secondPlayer] = 0;
	for(i = 0; i <  numDiscardEstateCards; i++)    //set Estate card number
	{
		G.discard[firstPlayer][i] = estate;
	}
	for(i = numDiscardEstateCards; i < length_3; i ++)  	//set Smithy card number in deck
	{
		G.discard[firstPlayer][i] = smithy;
	}

	//Test Estate Number - Player 1
	#if (NOISY_TEST == 1)
		printf("Calling fullDeckCount(Player 1, Estate Card)...\n");
	#endif 	
	returnEstate = fullDeckCount(firstPlayer, estate, &G);
	assert(ShouldBeEstateNumber == returnEstate);

	//Test Smithy Number - Player 1
	#if (NOISY_TEST == 1)
		printf("Calling fullDeckCount(Player 1, Smithy Card)...\n");
	#endif 
	returnSmithy = fullDeckCount(firstPlayer, smithy, &G);
	assert(ShouldBeSmithyNumber == returnSmithy);

	//Test Estate Number - Player 2
	#if (NOISY_TEST == 1)
		printf("Calling fullDeckCount(Player 2, Estate Card)...\n");
	#endif 
	returnZero = fullDeckCount(secondPlayer, estate, &G);
	assert(ShouldBeZero == returnZero);

	printf("Unit Test Passed\n");
}
